"""
    Author:
    Date: 2018-12-18

    微信管理后台-直播监控
"""

from django.shortcuts import render

from entities import err
from entities import cast_mgr

from .. import helpers
from .. helpers import gma_login_required


@gma_login_required
def index(request):
    """ 代理管理首页 """
    channel_data = cast_mgr.get_cast_channel_list()
    if channel_data is None:
        return helpers.show_page_500(request, err.ERROR_SYSTEM_ERROR)

    context = helpers.build_context(request)
    context['total_size'] = channel_data['total_size']
    context['channels'] = channel_data['channels']
    return render(request, 'gma/cast/cast_home.html', context)


if __name__ == '__main__':
    print('ok')
